package com.itheima.mall.web.ums;

import com.itheima.mall.api.ums.UmsRoleServiceApi;
import com.itheima.mall.pojo.ums.UmsRole;
import com.itheima.mall.service.ums.UmsRoleService;
import com.itheima.mall.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.aggregation.ArrayOperators;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("role")
public class UmsRoleController {

    @Autowired
    UmsRoleService umsRoleService;

    @PostMapping("create")
    public R UmsRoleCreate(@RequestBody UmsRole umsRole){
        return umsRoleService.UmsRoleCreate(umsRole);
    }

    @PostMapping("delete")
    public R UmsRoleDelete(Long[] ids){
        return umsRoleService.UmsRoleDelete(ids);
    }

    @GetMapping("list")
    public R UmsRoleList(String keyword, Integer pageNum, Integer pageSize){
        return umsRoleService.UmsRoleList(keyword,pageNum,pageSize);
    }

    @GetMapping("listAll")
    public R UmsRoleListAll(){
        return umsRoleService.UmsRoleListAll();
    }

    @PostMapping("update/{id}")
    public R UmsRoleUpdate(@PathVariable Long id, @RequestBody UmsRole umsRole){
        return umsRoleService.UmsRoleUpdate(id,umsRole);
    }

    @PostMapping("updateStatus/{id}")
    public R UmsRoleUpdateStatus(@PathVariable Long id, Integer status){
        return umsRoleService.UmsRoleUpdateStatus(id,status);
    }

    @PostMapping("allocMenu")
    public R UmsRoleAllocMenu(Long[] menuIds, Long roleId){
        return umsRoleService.UmsRoleAllocMenu(menuIds,roleId);
    }

    @PostMapping("allocResource")
    public R UmsRoleAllocResource(Long[] resourceIds, Long roleId){
        return umsRoleService.UmsRoleAllocResource(resourceIds,roleId);
    }

    @GetMapping("listMenu/{id}")
    public R UmsRoleListMenu(@PathVariable Long id){
        return umsRoleService.UmsRoleListMenu(id);
    }

    @GetMapping("listResource/{id}")
    public R UmsRoleListResource(@PathVariable Long id){
        return umsRoleService.UmsRoleListResource(id);
    }

}
